package com.emagic.manage.data.db.entry;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.annotation.ToOne;

import java.util.List;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;

/**
 * 设备信息表
 * Created by xiatian on 2017/8/14.
 */

@Entity
public class DeviceInfo {

    //设备信息：服务端唯一标识(row_id)，
    // 设备类型标识(type_id)，社区标识(community_id)，
    // 二维码标识(qrcode)，设备编码(equipment_code)，设备名称(equipment_name)，
    // 设备型号(equipment_model)，生产厂商(manufacturer)，设备图片(equipment_pic)，
    // 设备位置(equipment_location)，设备参数(parameter)，安装日期(install_date)，
    // 巡检次数(inspection_num)，保养次数(maintain_num)，维修次数(repair_num),设备标记状态(state)，备注(remark)

    @Id
    private String rowId;

    private Long typeId;

    private Long communityId;

    private String qrcode;

    private String equipmentCode;

    private String equipmentName;

    private String equipmentModel;

    private String manufacturer;

    private String equipmentPic;

    private String equipmentLocation;

    private String parameter;

    private String installDate;

    private String inspectionNum;

    private String maintainNum;

    private String repairNum;

    private String state;

    private String remark;

    @ToOne(joinProperty = "typeId")
    private DeviceType deviceType;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 1956318327)
    private transient DeviceInfoDao myDao;

    @Generated(hash = 5006837)
    public DeviceInfo(String rowId, Long typeId, Long communityId, String qrcode,
            String equipmentCode, String equipmentName, String equipmentModel,
            String manufacturer, String equipmentPic, String equipmentLocation,
            String parameter, String installDate, String inspectionNum, String maintainNum,
            String repairNum, String state, String remark) {
        this.rowId = rowId;
        this.typeId = typeId;
        this.communityId = communityId;
        this.qrcode = qrcode;
        this.equipmentCode = equipmentCode;
        this.equipmentName = equipmentName;
        this.equipmentModel = equipmentModel;
        this.manufacturer = manufacturer;
        this.equipmentPic = equipmentPic;
        this.equipmentLocation = equipmentLocation;
        this.parameter = parameter;
        this.installDate = installDate;
        this.inspectionNum = inspectionNum;
        this.maintainNum = maintainNum;
        this.repairNum = repairNum;
        this.state = state;
        this.remark = remark;
    }

    @Generated(hash = 2125166935)
    public DeviceInfo() {
    }

    public String getRowId() {
        return this.rowId;
    }

    public void setRowId(String rowId) {
        this.rowId = rowId;
    }

    public Long getTypeId() {
        return this.typeId;
    }

    public void setTypeId(Long typeId) {
        this.typeId = typeId;
    }

    public Long getCommunityId() {
        return this.communityId;
    }

    public void setCommunityId(Long communityId) {
        this.communityId = communityId;
    }

    public String getQrcode() {
        return this.qrcode;
    }

    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
    }

    public String getEquipmentCode() {
        return this.equipmentCode;
    }

    public void setEquipmentCode(String equipmentCode) {
        this.equipmentCode = equipmentCode;
    }

    public String getEquipmentName() {
        return this.equipmentName;
    }

    public void setEquipmentName(String equipmentName) {
        this.equipmentName = equipmentName;
    }

    public String getEquipmentModel() {
        return this.equipmentModel;
    }

    public void setEquipmentModel(String equipmentModel) {
        this.equipmentModel = equipmentModel;
    }

    public String getManufacturer() {
        return this.manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    public String getEquipmentPic() {
        return this.equipmentPic;
    }

    public void setEquipmentPic(String equipmentPic) {
        this.equipmentPic = equipmentPic;
    }

    public String getEquipmentLocation() {
        return this.equipmentLocation;
    }

    public void setEquipmentLocation(String equipmentLocation) {
        this.equipmentLocation = equipmentLocation;
    }

    public String getParameter() {
        return this.parameter;
    }

    public void setParameter(String parameter) {
        this.parameter = parameter;
    }

    public String getInstallDate() {
        return this.installDate;
    }

    public void setInstallDate(String installDate) {
        this.installDate = installDate;
    }

    public String getInspectionNum() {
        return this.inspectionNum;
    }

    public void setInspectionNum(String inspectionNum) {
        this.inspectionNum = inspectionNum;
    }

    public String getMaintainNum() {
        return this.maintainNum;
    }

    public void setMaintainNum(String maintainNum) {
        this.maintainNum = maintainNum;
    }

    public String getRepairNum() {
        return this.repairNum;
    }

    public void setRepairNum(String repairNum) {
        this.repairNum = repairNum;
    }

    public String getState() {
        return this.state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getRemark() {
        return this.remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Generated(hash = 978920425)
    private transient Long deviceType__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 2090440499)
    public DeviceType getDeviceType() {
        Long __key = this.typeId;
        if (deviceType__resolvedKey == null || !deviceType__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            DeviceTypeDao targetDao = daoSession.getDeviceTypeDao();
            DeviceType deviceTypeNew = targetDao.load(__key);
            synchronized (this) {
                deviceType = deviceTypeNew;
                deviceType__resolvedKey = __key;
            }
        }
        return deviceType;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 892123110)
    public void setDeviceType(DeviceType deviceType) {
        synchronized (this) {
            this.deviceType = deviceType;
            typeId = deviceType == null ? null : deviceType.getRowId();
            deviceType__resolvedKey = typeId;
        }
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1233815869)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getDeviceInfoDao() : null;
    }


}
